package com.zimin.cloud.user.controller;

import com.zimin.cloud.mine.pojo.user.business.UserMomentsBO;
import com.zimin.cloud.user.biz.IUserMomentsBiz;
import com.zimin.cloud.user.common.util.ServletUtil;
import com.zimin.cloud.user.controller.api.IUserMomentsController;
import com.zimin.shared.pojo.BaseController;
import com.zimin.shared.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户动态表 前端控制器
 * </p>
 *
 * @author zimin
 * @since 2022-06-14 16:10
 */
@RestController
public class UserMomentsController extends BaseController implements IUserMomentsController {

    @Autowired
    private IUserMomentsBiz userMomentsBiz;

    @Override
    public Result addUserMoments(UserMomentsBO userMomentsBO) throws Exception {
        var userId = ServletUtil.getCurrentUserId();
        userMomentsBO.setUserId(userId);
        return result(userMomentsBiz.save(userMomentsBO));
    }

    @Override
    public Result getUserSubscribedMoments() {
        var userId = ServletUtil.getCurrentUserId();
        var userMomentsList =  userMomentsBiz.getUserSubscribedMoments(userId);
        return result(userMomentsList);
    }
}
